<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="b" uri="/b2b-tags"%>
<div class="pro_list fr"  >
   <div class="title"  >
   	 <span class="titletxt">您现在的位置：</span>
     <ul> 
       <li class="root">会员中心</li>        
       <li>其他管理</li>  
       <li>投诉建议</li>            
     </ul>
   </div>
  <c:if test="${not empty ret }">
   	<c:if test="${ret.code ne '200'}">
   		<script type="text/javascript">alertError('${ret.result}');</script>
   		<div id=messager class="messager" >
	         <div class="contentmsg">
	             <h5>提示信息～！</h5>
	             <ul>
	               <li>${ret.result}</li>
	             </ul>
	        </div>
	     <div class="closer" onClick="showHideLayer('messager');" title="关闭"></div>
	    </div>
   	</c:if>
   </c:if>
   <br/>
   <div class="easyui-tabs"   >
		<div title="回复查询" style="padding:10px;">
			<div data-options="region:'center',split:true" style="width: 100%;height: 460px">
				<table id="tableGrid"></table>
			</div>
		</div>
   </div>
</div>
                         
<script>
var productsTable;
$(function(){
	initProducts();
});

function initProducts(){
	productsTable = $('#tableGrid').pDataGrid({
		 columns:[[
		          {field:'typeName',title:'类型',align:'center',sortable:true},
	          	  {field:'complaintTitle',title:'标题',align:'center',sortable:true},
	          	  {field:'complaintContent',title:'内容',align:'center',sortable:true},
	          	  {field:'connectPhone',title:'电话',align:'center',sortable:true},
	          	  {field:'createDate',title:'提交时间',align:'center',sortable:true, formatter:function(value,row,index){  
                      var unixTimestamp = new Date(value);  
                      return unixTimestamp.toLocaleString();  
                      } },
	          	  {field:'repplyStatus',title:'回复状态',align:'center',sortable:true,formatter:function(value,row){
	          		 str = "";
					  if(value==0){
						  str = "未回复"
					  }else{
						  str = "已回复";
					  }
					  return str;
		          	 }},
	          	  {field:'action',title:'操作',align:'center',sortable:true,formatter:function(value,row){
					if(row.repplyStatus==1){
						return '<a href="#" onclick="viewRepply('+row.complaintId+')">查看回复</a>';
					}
					if(row.repplyStatus==0){
						return '<a href="#" onclick="deleteSuggest('+row.complaintId+')">删除</a>';
					}
		          }}
		          ]],
		    url:'<c:url value="/complaint/searchPageEmBComplaint.s"/>',  
		    pagination:true,
		    pageSize:10,
		    queryParams:{
		    	 
		    },
			completeCallback:function(data){
				if(data.code == "100"){
					layer.msg(data.result);
				} 
			}
	}); 
}

//查看回复
function viewRepply(id){
	var params = {"complaintId":id}
	$.pmsDialog({
		id:"w_list",
		title:'查看回复',
		method:'post',
		params:params,
		href:'<c:url value="/views/jsp/center/other/user_suggest_reply.jsp"/>',
		width:700,
		height:500
	});
}

//删除投诉建议
function deleteSuggest(id){
	if(confirm("确定删除投诉建议？")){
		var param = {"complaintId":id};
		$.pmsAjax({
			url:'<c:url value="/complaint/deleteEmBComplaint.s"/>',
			data:param,
			success:function(data){
				if(data.code=="200"){
					layer.msg("删除成功",1, {type: 1,shade: [0.2, '#ccc']});
					initProducts();
				}else{
					alertError(data.result);
				}
			}
		});
	}
}
</script>